package com.wm.wmcrm.sys.controller;

import com.wm.wmcrm.common.annotation.SystemLog;
import com.wm.wmcrm.common.util.PageUtils;
import com.wm.wmcrm.sys.model.SysLogQueryDTO;
import com.wm.wmcrm.sys.model.SysRoleQueryDTO;
import com.wm.wmcrm.sys.service.ISysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author wm
 * @since 2023-02-24
 */
@Api(tags = "操作记录",value = "SysLog")
@RestController
@RequestMapping("/sys/sysLog")
public class SysLogController {
    @Resource
    private ISysLogService sysLogService;


    @ApiOperation(value = "查询操作列表",notes = "操作列表")
    @GetMapping("/queryList")
    public PageUtils queryList(@ApiParam(value = "操作名称") SysLogQueryDTO queryDTO){
        return sysLogService.queryList(queryDTO);
    }


    @SystemLog("删除操作记录")
    @ApiOperation(value = "删除操作记录",notes = "操作记录")
    @GetMapping("/deleteOne")
    public boolean deleteOne(@ApiParam(value = "操作记录id") String id){
        return sysLogService.removeById(id);
    }


    @SystemLog("批量删除操作记录")
    @ApiOperation(value = "批量删除操作记录",notes = "操作记录")
    @PostMapping("/deleteList")
    public int deleteList(@ApiParam(value = "操作记录List") @RequestBody List<String> ids){
        return sysLogService.getBaseMapper().deleteBatchIds(ids);
    }
}
